package io.github.biezhi.elves.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import io.github.biezhi.elves.bidding.model.BiddingDO;
import io.github.biezhi.elves.bidding.model.BiddingKeywordDO;
import io.github.biezhi.elves.bidding.model.BiddingListDO;
import io.github.biezhi.elves.bidding.model.ChangeNoticeDTO;
import io.github.biezhi.elves.bidding.model.DownloadBiddingHtmlDO;
import io.github.biezhi.elves.bidding.model.NoticeTypeDO;
import io.github.biezhi.elves.bidding.model.PurchaseModeDO;
import io.github.biezhi.elves.bidding.model.RecordBiddingNoticeDO;
import io.github.biezhi.elves.bidding.model.BiddingListQuery;
import io.github.biezhi.elves.bidding.model.RecordNoticeQuery;
import io.github.biezhi.elves.bidding.model.ResolveBiddingDO;
import io.github.biezhi.elves.bidding.model.ResolveBiddingQuery;
import io.github.biezhi.elves.bidding.model.WinBiddingDO;
import io.github.biezhi.elves.model.BiddingQuery;

public interface BidMapper {
	/***************************************新增操作 开始**********************************************************************/
	/**
	 * 新增发标公告数据
	 * @param	bidNotice	参数说明：发标公告DO对象
	 */
	@Insert("INSERT INTO t_bidding (record_id, bidder, project_name, project_code, agency_number_code, bidding_price, marking_time, bidding_time, purchase_id, notice_id, file_path, pubdate) "
			+"VALUES (#{recordId}, #{bidder}, #{projectName}, #{projectCode}, #{agencyNumberCode},  #{biddingPrice}, #{markingTime}, #{biddingTime}, #{purchaseId}, #{noticeId}, #{filePath}, #{pubdate})")
	@Options(keyColumn = "id", keyProperty = "id", useGeneratedKeys = true)
	void saveBidding(BiddingDO bidding);
	
	/**
	 * 新增中标公告数据
	 * @param	winBidding	参数说明：中标公告DO对象
	 */
	@Insert("INSERT INTO t_win_bidding (winning_bidder,record_id,customer,publish_time,budget,project_name, project_code, agency_number_code, winning_bid_price, bidding_time, purchase_id, notice_id, file_path,pubdate) "
			+"VALUES (#{winningBidder},#{recordId},#{customer},#{publishTime},#{budget},#{projectName}, #{projectCode}, #{agencyNumberCode}, #{winningBidPrice}, #{biddingTime}, #{purchaseId}, #{noticeId}, #{filePath},#{pubdate})")
	@Options(keyColumn = "id", keyProperty = "id", useGeneratedKeys = true)
	void saveWinBidding(WinBiddingDO winBidding);
	
	/**
	 * 新增记录投标网公告标题数据
	 * @param	recordBiddingNotice	参数说明：投标网公告标题DO对象
	 */
	@Insert("INSERT INTO t_record_bidding_notice (record_id, notice_type, purchase_mode, keyword, title,"
			+"notice_detail_url, size, operation_mode, pubdate, site_name) "
			+"VALUES (#{recordId}, #{noticeType}, #{purchaseMode}, #{keyword}, #{title},"
			+"#{noticeDetailUrl}, #{size}, #{operationMode}, #{pubdate}, #{siteName})")
	@Options(keyColumn = "id", keyProperty = "id", useGeneratedKeys = true)
	void saveRecordBiddingNotice(RecordBiddingNoticeDO recordBiddingNotice);
	
	/**
	 * 新增变更公告
	 * @param	changeNoticeDTO	参数说明：投标网公告标题DO对象
	 */
	@Insert("INSERT INTO t_change_notice (id, record_id, project_code, channel_notice_html) "
			+"VALUES (#{id}, #{recordId}, #{projectCode}, #{channelNoticeHtml})")
	void saveChangeNotice(ChangeNoticeDTO changeNoticeDTO);
	
	/**
	 * 新增下载投标网html数据
	 * @param	recordBiddingNotice	参数说明：投标网公告标题DO对象
	 */
	@Insert("INSERT INTO t_download_bidding_html (record_id, notice_type, purchase_mode, keyword,"
			+ "html_content, iframe_html_content, download_file, pubdate) "
			+"VALUES (#{recordId}, #{noticeType}, #{purchaseMode}, #{keyword}, #{htmlContent}, #{iframeHtmlContent},"
			+"#{downloadFile}, #{pubdate})")
	@Options(keyColumn = "id", keyProperty = "id", useGeneratedKeys = true)
	void saveDownloadBiddingHtml(DownloadBiddingHtmlDO downloadBiddingHtml);
	
	/**
	 * 新增公告清单存量数据(重复)
	 * @param	bidding		参数说明：公告清单DO对象
	 */
	@Insert("INSERT INTO t_bidding_stock_repeat (NOTICE_TITLE, PRJ_ID, PRJ_NAME, NOTICE_NAME, BUY_TYPE, CUSTOMER, SUPPLIER,"
			+"BUDGET, BID_PRICE, PUBLISH_TIME, DEAL_TIME, INDUSTRY, BID_URL, CITY, IS_SPECIAL, SPECIAL_NAME,"
			+"PUBDATE, NOTICE_HTML, NOTICE_IFRAME_HTML, IS_MANUAL, SITE_NAME) "
			+"VALUES (#{noticeTitle} ,#{prjId}, #{prjName}, #{noticeName}, #{buyType}, #{customer}, #{supplier}, #{budget}, #{bidPrice},"
			+"#{publishTime}, #{dealTime}, #{industry}, #{bidUrl}, #{city}, #{special}, #{specialName}, #{pubdate}, #{noticeHtml}, "
			+"#{noticeIframeHtml}, #{manual}, #{siteName})")
	@Options(keyColumn = "id", keyProperty = "id", useGeneratedKeys = true)
	void saveBiddingStockRepeat(BiddingListDO bidding);

	/**
	 * 新增存量公告清单数据
	 * @param	biddingStock		参数说明：存量公告清单DO对象
	 */
	@Insert("INSERT INTO t_bidding_stock (NOTICE_TITLE, PRJ_ID, PRJ_NAME, NOTICE_NAME, BUY_TYPE, CUSTOMER, SUPPLIER,"
			+"BUDGET, BID_PRICE, PUBLISH_TIME, DEAL_TIME, INDUSTRY, BID_URL, CITY, IS_SPECIAL, SPECIAL_NAME,"
			+"PUBDATE, STRATEGIC_CUSTOMER, NOTICE_HTML, NOTICE_IFRAME_HTML, IS_MANUAL, IS_SAVE, SITE_NAME) "
			+"VALUES (#{noticeTitle} ,#{prjId}, #{prjName}, #{noticeName}, #{buyType}, #{customer}, #{supplier}, #{budget}, #{bidPrice},"
			+"#{publishTime}, #{dealTime}, #{industry}, #{bidUrl}, #{city}, #{special}, #{specialName}, #{pubdate}, #{strategicCustomer},"
			+"#{noticeHtml}, #{noticeIframeHtml}, #{manual}, #{save}, #{siteName})")
	@Options(keyColumn = "id", keyProperty = "id", useGeneratedKeys = true)
	void saveResolveBiddingStock(ResolveBiddingDO biddingStock);
	
	/**
	 * 新增处理解析公告清单数据
	 * @param	bidding		参数说明：公告清单DO对象
	 */
	@Insert("INSERT INTO t_bidding_list (NOTICE_TITLE, PRJ_ID, PRJ_NAME, NOTICE_NAME, BUY_TYPE, CUSTOMER, SUPPLIER,"
			+"BUDGET, BID_PRICE, PUBLISH_TIME, DEAL_TIME, INDUSTRY, BID_URL, CITY, IS_SPECIAL, SPECIAL_NAME, PUBDATE,"
			+"PRJ_TYPE, STRATEGIC_CUSTOMER, MATCH_KEYWORD, NOTICE_HTML, NOTICE_IFRAME_HTML, IS_MANUAL, CREATE_TIME, SITE_NAME) "
			+"VALUES (#{noticeTitle} ,#{prjId}, #{prjName}, #{noticeName}, #{buyType}, #{customer}, #{supplier}, #{budget}, #{bidPrice},"
			+"#{publishTime}, #{dealTime}, #{industry}, #{bidUrl}, #{city}, #{special}, #{specialName}, #{pubdate}, #{prjType},"
			+"#{strategicCustomer}, #{matchKeyword}, #{noticeHtml}, #{noticeIframeHtml}, #{manual}, #{createTime}, #{siteName})")
	@Options(keyColumn = "id", keyProperty = "id", useGeneratedKeys = true)
	void saveResolveBiddingList(BiddingListDO bidding);
	/***************************************新增操作 结束**********************************************************************/
	
	/***************************************更新操作 开始**********************************************************************/
	/**
	 * 更新记录投标网公告标题数据
	 * @param	operationMode		参数说明：操作方式
	 * @param	id							参数说明：取的是网站上的标题链接的后缀作为标题id
	 */
	@Update("UPDATE t_record_bidding_notice SET operation_mode = #{operationMode} "
			+"WHERE id = #{id}")
	void updateRecordBiddingNotice(@Param("operationMode") String operationMode, @Param("id") Long id);
	
	/**
	 * 更新存量公告清单数据表保存标识为1
	 * @param id		参数说明：id
	 */
	@Update("UPDATE ${tableName} SET IS_SAVE = #{save} "
			+"WHERE id = #{id}")
	void updateBiddingListStock(@Param("tableName") String tableName, @Param("save") Integer save, @Param("id") Long id);
	
	/**
	 * 更新公告数据表为空的公告标题数据
	 * @param prjId		参数说明：项目编号
	 */
	@Update("UPDATE t_bidding_stock_import SET NOTICE_TITLE = #{noticeTitle} "
			+"WHERE PRJ_ID = #{prjId}")
	void updateBiddingStockImport(@Param("noticeTitle") String noticeTitle, @Param("prjId") String prjId);
	
	/**
	 * 更新公告数据表htmlContent数据
	 * @param downloadBiddingHtml		参数说明：下载对象
	 */
	@Update("UPDATE t_download_bidding_html SET html_content = #{htmlContent} "
			+"WHERE record_id = #{recordId}")
	void updateDownloadBiddingForHtmlContent(DownloadBiddingHtmlDO downloadBiddingHtml);
	
	/**
	 * 更新公告数据表iframeHtmlContent数据
	 * @param downloadBiddingHtml		参数说明：下载对象
	 */
	@Update("UPDATE t_download_bidding_html SET iframe_html_content = #{iframeHtmlContent} "
			+"WHERE record_id = #{recordId}")
	void updateDownloadBiddingForIframeHtmlContent(DownloadBiddingHtmlDO downloadBiddingHtml);
	/***************************************更新操作 结束**********************************************************************/
	
	/***************************************查询操作 开始**********************************************************************/
	/**
	 * 统计未解析投标网公告标题数据
	 * @return	统计未解析投标网公告标题数据
	 */
	@Select("SELECT count(*) FROM t_record_bidding_notice "
			+"WHERE operation_mode = 2")
	Integer countRecordBiddingNotice();
	
	/**
	 * 根据记录id和标题查询记录表中是否存在公告标题id
	 * @param query
	 * @return	记录表中是否存在公告标题id
	 */
	@Select("SELECT count(*) FROM t_record_bidding_notice "
			+"WHERE id = #{id}")
	Integer countRecordBiddingNoticeById(BiddingQuery query);
	
	/**
	 * 根据标题查询记录表中是否存在公告标题id
	 * @param query
	 * @return	记录表中是否存在公告标题id
	 */
	@Select("SELECT count(*) FROM t_record_bidding_notice "
			+"WHERE title = #{title}")
	Integer countRecordBiddingNoticeByTitle(BiddingQuery query);
	
	/**
	 * 根据记录id、公告类型、采购方式、标题查询记录表中是否存在公告标题id
	 * @param query
	 * @return	记录表中是否存在公告标题id
	 */
	@Select("SELECT count(*) FROM t_record_bidding_notice "
			+"WHERE id = #{id} "
			+"AND notice_type = #{noticeType} "
			+"AND purchase_mode = #{purchaseMode} "
			+"AND title = #{title}")
	Integer countRecordBiddingNoticeByQuery(BiddingQuery query);
	
	/**
	 * 根据记录id查询下载html数据表中是否存在公告标题id
	 * @param query
	 * @return	下载html数据表中是否存在公告标题id
	 */
	@Select("SELECT count(*) FROM t_download_bidding_html "
			+"WHERE record_id = #{recordId} "
			+"AND pubdate = #{pubdate}")
	Integer countDownloadBiddingHtmlById(BiddingQuery query);
	
	/**
	 * 根据记录id和关键字查询下载html数据表中是否存在公告标题id
	 * @param query
	 * @return	下载html数据表中是否存在公告标题id
	 */
	@Select("SELECT count(*) FROM t_download_bidding_html "
			+"WHERE id = #{id} "
			+"AND keyword = #{keyword}")
	Integer countDownloadBiddingHtmlByQuery(BiddingQuery query);
	
	/**
	 * 根据表名和关键字统计指定表数据是否存在表中
	 * @param	tableName	参数说明：表名
	 * @param	keyword		参数说明：关键字
	 * @param	noticeType	参数说明：公告类型
	 * @return	统计指定表数据是否存在表中
	 */
	@Select("SELECT count(*) FROM ${tableName} "
			+"WHERE keyword = #{keyword} "
			+"AND notice_type = #{noticeType}")
	Integer countByKeyword(@Param("tableName") String tableName, @Param("keyword") String keyword, @Param("noticeType") String noticeType);
	
	/**
	 * 根据项目编号、公告标题、供应商和中标金额统计是否已存在解析过的数据
	 * @param query
	 * @return
	 */
	@Select("SELECT count(*) FROM t_bidding_list "
			+"WHERE NOTICE_TITLE = #{noticeTitle} "
			+"AND PRJ_ID = #{prjId} "
			+"AND SUPPLIER = #{supplier} "
			+"AND BID_PRICE = #{bidPrice}")
	Integer countResolveHtml(BiddingListQuery query);
	
	/**
	 * 根据项目编号、供应商和中标金额统计过滤数据重复
	 * @param query
	 * @return
	 */
	@Select("SELECT count(*) FROM ${tableName} "
			+"WHERE PRJ_NAME = #{prjName} "
			+"AND SUPPLIER = #{supplier} "
			+"AND BID_PRICE = #{bidPrice}"
//			+"AND PRJ_ID IS NOT NULL "
//			+"AND SUPPLIER IS NOT NULL "
//			+"AND BID_PRICE IS NOT NULL"
			)
	Integer countResolveFilterRepeat(BiddingListQuery query);
	
	/**
	 * 查询初始化公告标题数据
	 * @param	operationMode		参数说明：操作方式
	 * @param	noticeType			参数说明：公告类型
	 * @return	公告标题数据集合
	 */
	@Select("<script>"
			+"SELECT id, record_id, notice_type, purchase_mode, keyword, title, notice_detail_url, size, operation_mode, pubdate "
			+"FROM t_record_bidding_notice "
			+"WHERE operation_mode = #{operationMode} "
			+"AND notice_type = #{noticeType} "
			+"AND (title like '%中标%' or  title like '%结果公告%' or  title like '%结果的通告%' or title like '%成交公告%') "
//			+"AND STR_TO_DATE(pubdate,'%Y-%m-%d') > STR_TO_DATE('2018-09-03','%Y-%m-%d') "
//			+"AND notice_detail_url like '%my.zbyjw.cn%' "
//			+"AND notice_detail_url like '%www.bidcenter.com%' "
			+"AND site_name = #{siteName} "
			+"ORDER BY size "
//			+"LIMIT #{size}, #{pageNo}"
			+"</script>")
	@Results({
		@Result(column = "id", property = "id", id = true),
		@Result(column = "record_id", property = "recordId"),
		@Result(column = "notice_type", property = "noticeType"),
		@Result(column = "purchase_mode", property = "purchaseMode"),
		@Result(column = "keyword", property = "keyword"),
		@Result(column = "title", property = "title"),
		@Result(column = "notice_detail_url", property = "noticeDetailUrl"),
		@Result(column = "size", property = "size"),
		@Result(column = "operation_mode", property = "operationMode"),
		@Result(column = "pubdate", property = "pubdate")
	})
	List<RecordBiddingNoticeDO> listRecordBiddingNotice(RecordNoticeQuery query);
	
	/**
	 * 查询公告详情页面数据
	 * @return	公告详情页面数据集合
	 */
	@Select("SELECT id, record_id, notice_type, purchase_mode, keyword, html_content, download_file "
			+"FROM t_download_bidding_html")
	@Results({
		@Result(column = "id", property = "id", id = true),
		@Result(column = "record_id", property = "recordId"),
		@Result(column = "notice_type", property = "noticeType"),
		@Result(column = "purchase_mode", property = "purchaseMode"),
		@Result(column = "keyword", property = "keyword"),
		@Result(column = "html_content", property = "htmlContent"),
		@Result(column = "download_file", property = "downloadFile")
	})
	List<DownloadBiddingHtmlDO> listDownloadBiddingHtml();
	
	/**
	 * 查询下载公告html为空的数据
	 * @return
	 */
	@Select("SELECT id, record_id, notice_type, purchase_mode, keyword, html_content, iframe_html_content, download_file "
			+"FROM t_download_bidding_html  WHERE html_content = ''")
	@Results({
		@Result(column = "id", property = "id", id = true),
		@Result(column = "record_id", property = "recordId"),
		@Result(column = "notice_type", property = "noticeType"),
		@Result(column = "purchase_mode", property = "purchaseMode"),
		@Result(column = "keyword", property = "keyword"),
		@Result(column = "html_content", property = "htmlContent"),
		@Result(column = "iframe_html_content", property = "iframeHtmlContent"),
		@Result(column = "download_file", property = "downloadFile")
	})
	List<DownloadBiddingHtmlDO> listDownloadBiddingHtmlIsNullHtmlContent();
	
	/**
	 * 查询下载公告iframe的html为空的数据
	 * @return
	 */
	@Select("SELECT id, record_id, notice_type, purchase_mode, keyword, html_content, iframe_html_content, download_file "
			+"FROM t_download_bidding_html "
			+"WHERE record_id in ("
			+"SELECT record_id FROM t_record_bidding_notice "
			+"WHERE site_name = '采标网'"
			+") "
			+"AND iframe_html_content is null "
			+"LIMIT 0, 50")
	@Results({
		@Result(column = "id", property = "id", id = true),
		@Result(column = "record_id", property = "recordId"),
		@Result(column = "notice_type", property = "noticeType"),
		@Result(column = "purchase_mode", property = "purchaseMode"),
		@Result(column = "keyword", property = "keyword"),
		@Result(column = "html_content", property = "htmlContent"),
		@Result(column = "iframe_html_content", property = "iframeHtmlContent"),
		@Result(column = "download_file", property = "downloadFile")
	})
	List<DownloadBiddingHtmlDO> listDownloadBiddingHtmlIsNullIframeHtmlContent();
	
	/**
	 * 根据记录ID查询公告详情页面数据
	 * @param	recordId	参数说明：记录ID
	 * @return	公告详情页面数据
	 */
	@Select("SELECT id, record_id, notice_type, purchase_mode, keyword, html_content, iframe_html_content, download_file, pubdate "
			+"FROM t_download_bidding_html "
			+"WHERE record_id = #{recordId}")
	@Results({
		@Result(column = "id", property = "id", id = true),
		@Result(column = "record_id", property = "recordId"),
		@Result(column = "notice_type", property = "noticeType"),
		@Result(column = "purchase_mode", property = "purchaseMode"),
		@Result(column = "keyword", property = "keyword"),
		@Result(column = "html_content", property = "htmlContent"),
		@Result(column = "iframe_html_content", property = "iframeHtmlContent"),
		@Result(column = "download_file", property = "downloadFile"),
		@Result(column = "pubdate", property = "pubdate")
	})
	DownloadBiddingHtmlDO downloadBiddingHtmlByRecordId(@Param("recordId") String recordId);
	
	/**
	 * 根据记录ID查询公告详情页面数据
	 * @param	recordId	参数说明：记录ID
	 * @return	公告详情页面数据
	 */
	@Select("SELECT id, record_id, notice_type, purchase_mode, keyword, html_content, download_file "
			+"FROM t_download_bidding_html "
			+"WHERE notice_type = #{noticeType}")
	@Results({
		@Result(column = "id", property = "id", id = true),
		@Result(column = "record_id", property = "recordId"),
		@Result(column = "notice_type", property = "noticeType"),
		@Result(column = "purchase_mode", property = "purchaseMode"),
		@Result(column = "keyword", property = "keyword"),
		@Result(column = "html_content", property = "htmlContent"),
		@Result(column = "download_file", property = "downloadFile")
	})
	List<DownloadBiddingHtmlDO> downloadBiddingHtmlByNoticeType(@Param("noticeType") String noticeType);
	
	/**
	 * 查询公告类型数据
	 * @return	公告类型集合
	 */
	@Select("SELECT id, notice_id, notice_name FROM t_notice_type WHERE is_valid = 'T' order by visorder")
	@Results({
		@Result(column = "id", property = "id", id = true),
		@Result(column = "notice_id", property = "noticeId"),
		@Result(column = "notice_name", property = "noticeName")
	})
	List<NoticeTypeDO> listNoticeType();
	
	/**
	 * 查询采购方式数据
	 * @param noticeId	参数说明：公告ID
	 * @return	采购方式集合
	 */
	@Select("SELECT id, purchase_id, purchase_name, notice_id "
			+"FROM t_purchase_mode "
			+"WHERE notice_id = #{noticeId} "
			+"AND  is_valid = 'T'")
	@Results({
		@Result(column = "id", property = "id", id = true),
		@Result(column = "purchase_id", property = "purchaseId"),
		@Result(column = "purchase_name", property = "purchaseName"),
		@Result(column = "notice_id", property = "noticeId")
	})
	List<PurchaseModeDO> listPurchaseMode(@Param("noticeId") String noticeId);
	
	/**
	 * 查询关键字数据
	 * @return	关键字数据集合
	 */
	@Select("<script>"
			+"SELECT id, keyword, is_search, keyword_type "
			+"FROM t_bidding_keyword "
			+"WHERE is_search = 'T' "
			+"<if test = 'keywordType != null'>"
				+"AND keyword_type = #{keywordType}"
			+"</if>"
			+"</script>")
	@Results({
		@Result(column = "id", property = "id", id = true),
		@Result(column = "keyword", property = "keyword"),
		@Result(column = "is_search", property = "search"),
		@Result(column = "keyword_type", property = "keywordType")
	})
	List<BiddingKeywordDO> listBiddingKeyword(@Param("keywordType") Integer keywordType);
	
	/**
	 * 统计存量重复公告清单标识为未保存存量表(t_bidding_stock)的数据
	 * @return
	 */
	@Select("SELECT COUNT(1) FROM t_bidding_stock_repeat "
			+"WHERE CITY != '-1' "
			+"AND SITE_NAME = #{siteName} "
			+"AND IS_SAVE = 0")
	Integer countResolveBiddingStockRepeat(@Param("siteName") String siteName);
	
	/**
	 * 公告清单存量数据重复
	 * @return
	 */
	@Select("SELECT ID, NOTICE_TITLE, PRJ_ID, PRJ_NAME, NOTICE_NAME, BUY_TYPE, CUSTOMER,"
			+"SUPPLIER, BUDGET, BID_PRICE, PUBLISH_TIME, DEAL_TIME, INDUSTRY, BID_URL, CITY,"
			+"IS_SPECIAL, SPECIAL_NAME, PUBDATE, STRATEGIC_CUSTOMER, NOTICE_HTML, NOTICE_IFRAME_HTML, IS_MANUAL "
			+"FROM t_bidding_stock_repeat "
			+"WHERE CITY != '-1' "
//			+"AND BID_URL like '%my.zbyjw.cn%' "
			+"AND SITE_NAME = #{siteName} "
			+"AND IS_SAVE = 0 "
			+"LIMIT #{size}, #{pageNo}")
	@Results({
		@Result(column = "ID", property = "id", id = true),
		@Result(column = "NOTICE_TITLE", property = "noticeTitle"),
		@Result(column = "PRJ_ID", property = "prjId"),
		@Result(column = "PRJ_NAME", property = "prjName"),
		@Result(column = "NOTICE_NAME", property = "noticeName"),
		@Result(column = "BUY_TYPE", property = "buyType"),
		@Result(column = "CUSTOMER", property = "customer"),
		@Result(column = "SUPPLIER", property = "supplier"),
		@Result(column = "BUDGET", property = "budget"),
		@Result(column = "BID_PRICE", property = "bidPrice"),
		@Result(column = "PUBLISH_TIME", property = "publishTime"),
		@Result(column = "DEAL_TIME", property = "dealTime"),
		@Result(column = "INDUSTRY", property = "industry"),
		@Result(column = "BID_URL", property = "bidUrl"),
		@Result(column = "CITY", property = "city"),
		@Result(column = "IS_SPECIAL", property = "special"),
		@Result(column = "SPECIAL_NAME", property = "specialName"),
		@Result(column = "PUBDATE", property = "pubdate"),
		@Result(column = "STRATEGIC_CUSTOMER", property = "strategicCustomer"),
		@Result(column = "NOTICE_HTML", property = "noticeHtml"),
		@Result(column = "NOTICE_IFRAME_HTML", property = "noticeIframeHtml"),
		@Result(column = "IS_MANUAL", property = "manual")
	})
	List<ResolveBiddingDO> listResolveBiddingStockRepeatPage(ResolveBiddingQuery query);
	
	/**
	 * 公告清单存量数据
	 * @param query		参数说明：查询条件
	 * @return
	 */
	@Select("<script>"
			+"SELECT ID, NOTICE_TITLE, PRJ_ID, PRJ_NAME, NOTICE_NAME, BUY_TYPE, CUSTOMER,"
			+"SUPPLIER, BUDGET, BID_PRICE, PUBLISH_TIME, DEAL_TIME, INDUSTRY, BID_URL, CITY,"
			+"IS_SPECIAL, SPECIAL_NAME, PUBDATE, STRATEGIC_CUSTOMER, NOTICE_HTML, NOTICE_IFRAME_HTML, IS_MANUAL "
			+"FROM t_bidding_stock "
			+"WHERE CITY != '-1' "
//			+"AND BID_URL like '%my.zbyjw.cn%' "
//			+"AND STR_TO_DATE(pubdate,'%Y-%m-%d') > STR_TO_DATE('2018-08-27','%Y-%m-%d') "
			+"AND SITE_NAME = #{siteName} "
			+"AND IS_SAVE = 0 "
			+"LIMIT #{size}, #{pageNo}"
			+"</script>")
	@Results({
		@Result(column = "ID", property = "id", id = true),
		@Result(column = "NOTICE_TITLE", property = "noticeTitle"),
		@Result(column = "PRJ_ID", property = "prjId"),
		@Result(column = "PRJ_NAME", property = "prjName"),
		@Result(column = "NOTICE_NAME", property = "noticeName"),
		@Result(column = "BUY_TYPE", property = "buyType"),
		@Result(column = "CUSTOMER", property = "customer"),
		@Result(column = "SUPPLIER", property = "supplier"),
		@Result(column = "BUDGET", property = "budget"),
		@Result(column = "BID_PRICE", property = "bidPrice"),
		@Result(column = "PUBLISH_TIME", property = "publishTime"),
		@Result(column = "DEAL_TIME", property = "dealTime"),
		@Result(column = "INDUSTRY", property = "industry"),
		@Result(column = "BID_URL", property = "bidUrl"),
		@Result(column = "CITY", property = "city"),
		@Result(column = "IS_SPECIAL", property = "special"),
		@Result(column = "SPECIAL_NAME", property = "specialName"),
		@Result(column = "PUBDATE", property = "pubdate"),
		@Result(column = "PRJ_TYPE", property = "prjType"),
		@Result(column = "STRATEGIC_CUSTOMER", property = "strategicCustomer"),
		@Result(column = "NOTICE_HTML", property = "noticeHtml"),
		@Result(column = "NOTICE_IFRAME_HTML", property = "noticeIframeHtml"),
		@Result(column = "IS_MANUAL", property = "manual")
	})
	List<ResolveBiddingDO> listResolveBiddingStockPage(ResolveBiddingQuery query);
	
	/**
	 * 公告清单存量test数据
	 * @return
	 * throws Exception
	 */
	@Select("SELECT NOTICE_TITLE, PRJ_ID, PRJ_NAME, NOTICE_NAME, BUY_TYPE, CUSTOMER,"
			+"SUPPLIER, BUDGET, BID_PRICE, PUBLISH_TIME, DEAL_TIME, INDUSTRY, BID_URL, CITY,"
			+"IS_SPECIAL, SPECIAL_NAME, PUBDATE, STRATEGIC_CUSTOMER "
			+"FROM t_bidding_stock_import "
			+"WHERE BID_URL != '' "
//			+"AND BID_URL LIKE '%www.szzfcg.cn%' "
			+"AND BID_URL LIKE '%show.job592.com%' "
//			+"AND BID_URL LIKE '%www.zgazxxw.com%' "
//			+"AND BID_URL LIKE '%ggzy.zhuhai.gov.cn%' "
//			+"AND BID_URL LIKE '%www.gdgpo.gov.cn%' "
//			+"AND BID_URL LIKE '%www.cebpubservice.com%' "
//			+"AND BID_URL LIKE '%www.gdggzy.org.cn%' "
//			+"AND BID_URL LIKE '%www.gzggzy.cn%' "
			+"and BID_URL != 'http://www.gzggzy.cn/cms/wz/view/index/layout2/zfcglist.jsp?siteId=1&channelId=458' "
//			+"AND BID_URL LIKE '%ggzy.dg.gov.cn%' "
//			+"AND BID_URL LIKE '%ggzy.zhuhai.gov.cn%' "
//			+"AND BID_URL LIKE '%www.zgazxxw.com%' "
//			+"AND BID_URL LIKE '%www.gzswbc.com%' "
//			+"AND BID_URL LIKE '%www.mzggzy.com%' "
			+"AND NOTICE_TITLE = ''")
	@Results({
		@Result(column = "NOTICE_TITLE", property = "noticeTitle"),
		@Result(column = "PRJ_ID", property = "prjId"),
		@Result(column = "PRJ_NAME", property = "prjName"),
		@Result(column = "NOTICE_NAME", property = "noticeName"),
		@Result(column = "BUY_TYPE", property = "buyType"),
		@Result(column = "CUSTOMER", property = "customer"),
		@Result(column = "SUPPLIER", property = "supplier"),
		@Result(column = "BUDGET", property = "budget"),
		@Result(column = "BID_PRICE", property = "bidPrice"),
		@Result(column = "PUBLISH_TIME", property = "publishTime"),
		@Result(column = "DEAL_TIME", property = "dealTime"),
		@Result(column = "INDUSTRY", property = "industry"),
		@Result(column = "BID_URL", property = "bidUrl"),
		@Result(column = "CITY", property = "city"),
		@Result(column = "IS_SPECIAL", property = "special"),
		@Result(column = "SPECIAL_NAME", property = "specialName"),
		@Result(column = "PUBDATE", property = "pubdate"),
		@Result(column = "PRJ_TYPE", property = "prjType"),
		@Result(column = "STRATEGIC_CUSTOMER", property = "strategicCustomer")
	})
	List<BiddingListDO> listBiddingStockImportPage();
	
	/**
	 * 根据网站名称查询最新爬取的公告发布时间
	 * @param siteName		参数说明：网站名称
	 * @param keyword			参数说明：网站名称
	 * @return
	 */
	@Select("<script>"
			+"SELECT MAX(pubdate) as pubdate FROM t_record_bidding_notice "
			+"WHERE site_name = #{siteName} "
			+"<if test = 'keyword != null'>"
				+"AND keyword = #{keyword} "
			+"</if>"
			+"</script>")
	RecordBiddingNoticeDO getNewPubdateBySiteName(@Param("siteName") String siteName, @Param("keyword") String keyword);
	
	/**
	 * 根据关键字查询信息
	 * @param keyword		参数说明：关键字
	 * @return	关键字数据
	 */
	@Select("SELECT id, keyword, is_search, keyword_type "
			+"FROM t_bidding_keyword "
			+"WHERE is_search = 'T' "
			+"AND keyword = #{keyword}")
	@Results({
		@Result(column = "id", property = "id", id = true),
		@Result(column = "keyword", property = "keyword"),
		@Result(column = "is_search", property = "search"),
		@Result(column = "keyword_type", property = "keywordType")
	})
	BiddingKeywordDO getBiddingKeywordByKeyword(@Param("keyword") String keyword);
	/***************************************查询操作 结束**********************************************************************/
}